package com.example.mysql.entity;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.databind.util.JSONPObject;
import lombok.Data;
import lombok.experimental.Accessors;

import java.lang.reflect.Field;
import java.util.Date;

/**
 * @author chlin
 * @date 2019-12-13
 */
@Data
@Accessors(chain = true)
@TableName(value = "async_log")
public class AsyncLog {

    //异步线程ID
    @TableField(value = "THREAD_ID",updateStrategy = FieldStrategy.NOT_EMPTY)
    private Long threadId;

    @TableId(value="LOG_ID",type= IdType.AUTO)
    private Long logId;

    @TableField(value = "USER_NAME",updateStrategy = FieldStrategy.NOT_EMPTY)
    private String userName;

    //业务接口名称
    @TableField(value = "INTER_NAME",updateStrategy = FieldStrategy.NOT_NULL)
    private String interName;

    //业务接口所属系统
    @TableField(value = "SYS_CODE",updateStrategy = FieldStrategy.NOT_NULL)
    private String sysCode;

    @TableField(value = "SYS_NAME",updateStrategy = FieldStrategy.NOT_NULL)
    private String sysName;

    //接口类型（1 查询，2 申请，3 审批）
    //更细粒度的以后再说
    @TableField(value = "INTER_TYPE",updateStrategy = FieldStrategy.NOT_NULL)
    private int interType;

    //调用结果（1 成功 0000;2 失败：-9999,业务侧异常,返回值无法转换成Result对象;3 接口连接超时）
    @TableField(value = "RESULT",updateStrategy = FieldStrategy.NOT_NULL)
    private int result;

    //错误原因描述：-9999；返回信息不符合要求格式；连接超时；
    @TableField(value = "ERR_INFO",updateStrategy = FieldStrategy.NOT_NULL)
    private String errInfo;

    //调用时间
    @TableField(value = "CALL_DATE_TIME",updateStrategy = FieldStrategy.NOT_NULL)
    private Date callDatetime;

    //请求信息
    @TableField(value = "URI",updateStrategy = FieldStrategy.NOT_NULL)
    private String uri;

    @TableField(value = "METHOD",updateStrategy = FieldStrategy.NOT_NULL)
    private String method;

    private String requestHeaders;

    private String requestBody;

    //响应信息
    private String statusCode;

    private String statusText;

    private String responseHeaders;

    private String responseBody;

    @TableField(value = "CREATE_DATE_TIME",updateStrategy = FieldStrategy.IGNORED)
    private Date createDateTime;

    //response返回值code
    @TableField(value = "RESPONSE_CODE",updateStrategy = FieldStrategy.IGNORED)
    private String responseCode;

    public static void main(String[] args){
        Class<AsyncLog> asyncLogClass = AsyncLog.class;
        Field[] declaredFields = asyncLogClass.getDeclaredFields();
        StringBuilder sbr = new StringBuilder("{");
        for (int i = 0; i < declaredFields.length; i++) {
            sbr.append("\"").append(declaredFields[i].getName()).append("\"");
            sbr.append(":").append("\"\"");
            sbr.append(",");
        }
        sbr.append("}");
        System.out.println(sbr.toString());

    }

}